<%@ taglib uri="/tags/struts-bean" prefix="bean" %>
<%@ taglib uri="/tags/struts-html" prefix="html" %>
<%@ taglib uri="/tags/core" prefix="c"%>
<script type="text/javascript" src="js/jquery-1.8.min.js"></script>
<link rel="stylesheet" href="css/jquery-ui.css" type="text/css"/>
<script>
	$(function() {
		$( "#datepickerInit" ).datepicker({
			changeMonth: true,
			changeYear: true,
			yearRange:"c-10",
			minDate:"-10y",
			dateFormat: 'dd/mm/yy',
			});
		$( "#datepickerEnd" ).datepicker({
			changeMonth: true,
			changeYear: true,
			yearRange:"c-10",
			minDate:"-10y",
			dateFormat: 'dd/mm/yy',
			});
	});
	
	$(document).ready(function() {
		$("#saveButton").click(
			function () { 
				alert('Validando Formas!'); 
	    	}
		);
	});
</script>
<div style="display: inline-block;">
	<div class="view" style="display: inline-block;">
		<html:form action="/entries">
			<div class="ctable">
				<div class="cfilter label" style="margin-bottom: 10px;"><bean:message key="list.scales.filter.init.date"/>:</div>
				<div class="cfilter field" style="margin-bottom: 10px;">
					<html:text styleId="datepickerInit" readonly="true" property="siloDatesView.initDate" styleClass="textfields" style="height: 12px;padding-left: 2px;width: 59px;"></html:text> 08:00 AM
				</div>
				<div class="cfilter label" style="margin-bottom: 10px;"><bean:message key="list.scales.filter.end.date"/>:</div>
				<div class="cfilter field" style="margin-bottom: 10px;">
					<html:text styleId="datepickerEnd" readonly="true" property="siloDatesView.endDate" styleClass="textfields" style="height: 12px;padding-left: 2px;width: 59px;"></html:text> 08:00 AM
				</div>
				<div class="cfilter field" style="margin-bottom: 10px;">
					<html:submit styleClass="boton"><bean:message key="list.scales.filter.search"/></html:submit>
					<html:button onclick="location.href = 'welcome.do';" styleClass="boton" property="back"><bean:message key="list.scales.filter.back"/></html:button>
					<html:button styleId="saveButton" styleClass="boton" property="save"><bean:message key="list.scales.filter.save"/></html:button>
				</div>
			</div>
		</html:form>
		<div class="ctable">
			<div class="cheader">
				<div style="width: 374px" class="border-right"><bean:message key="list.scales"/></div>
				<div style="width: 802px;"><bean:message key="list.transits"/></div>
			</div>
			<div class="cheadertitle">
				<div style="width: 92px;" class="border-right"><bean:message key="list.scales.date"/></div>
				<div style="width: 42px;" class="border-right"><bean:message key="list.scales.origin"/></div>
				<div style="width: 72px;" class="border-right"><bean:message key="list.scales.wagon"/></div>
				<div style="width: 28px;" class="border-right"><bean:message key="list.scales.silo"/></div>
				<div style="width: 33px;" class="border-right"><bean:message key="list.scales.corn"/></div>
				<div style="width: 40px;" class="border-right"><bean:message key="list.scales.dampness"/></div>
				<div style="width: 60px;" class="border-right"><bean:message key="list.scales.weight"/></div>
				
				<div style="width: 20px;" class="border-right">&nbsp;</div>
				
				<div style="width: 45px;" class="border-right"><bean:message key="list.transits.initial"/></div>
				<div style="width: 50px;" class="border-right"><bean:message key="list.transits.number"/></div>
				<div style="width: 50px;" class="border-right"><bean:message key="list.transits.guide"/></div>
				<div style="width: 70px;" class="border-right"><bean:message key="list.transits.seal"/></div>
				<div style="width: 50px;" class="border-right"><bean:message key="list.transits.origin.weight"/></div>
				<div style="width: 55px;" class="border-right"><bean:message key="list.transits.origin.dampness"/></div>
				<div style="width: 65px;" class="border-right"><bean:message key="list.transits.document.date"/></div>
				<div style="width: 75px;" class="border-right"><bean:message key="list.transits.reception.date"/></div>
				<div style="width: 70px;" class="border-right"><bean:message key="list.transits.ticket"/></div>
				<div style="width: 70px;" class="border-right"><bean:message key="list.transits.weight"/></div>
				<div style="width: 60px;" class="border-right"><bean:message key="list.transits.dampness"/></div>
				<div style="width: 90px;" class="border-right"><bean:message key="list.transits.location"/></div>
				<div style="width: 20px;">&nbsp;</div>
			</div>
			<c:forEach var="siloEntryView" items="${SiloEntityForm.siloEntityViews}" varStatus="index">
				<div class="crow <c:choose><c:when test="${index.count%2==0}">odd</c:when><c:otherwise>even</c:otherwise></c:choose>">
					<div style="width: 92px;" class="border-right text-center"><c:out value="${siloEntryView.completedDate}"/></div>
					<div style="width: 42px;" class="border-right text-center"><c:out value="${siloEntryView.origin}"/></div>
					<div style="width: 70px;" class="border-right text-left"><c:out value="${siloEntryView.wagon}"/></div>
					<div style="width: 28px;" class="border-right text-center"><c:out value="${siloEntryView.locationView.locationId}"/></div>
					<div style="width: 33px;" class="border-right text-center" title="<c:out value="${siloEntryView.cornTypeView.description}"/>"><c:out value="${siloEntryView.cornTypeView.shortName}"/></div>
					<div style="width: 38px;" class="border-right text-right"><c:out value="${siloEntryView.wetness}"/></div>
					<div style="width: 58px;" class="border-right text-right"><c:out value="${siloEntryView.amount}"/></div>
					
					<div style="width: 20px;" class="border-right text-center-field">
						<c:if test="${siloEntryView.unitView != null}">
							<input type="checkbox" name="SiloEntityForm.save[<c:out value="${index.count}"/>]" checked="checked" style="margin-top: -2px;"/>
						</c:if>
					</div>
					<c:choose>
						<c:when test="${siloEntryView.unitView == null}">
							<div style="width: 782px;text-align: center;">&nbsp;</div>
						</c:when>
						<c:otherwise>
							<div style="width: 43px;" class="border-right text-left"><c:out value="${siloEntryView.unitView.initial}"></c:out></div>
							<div style="width: 48px;" class="border-right text-left"><c:out value="${siloEntryView.unitView.number}"></c:out></div>
							<div style="width: 50px;" class="border-right text-center"><c:out value="${siloEntryView.unitView.guide}"></c:out></div>
							<div style="width: 70px;" class="border-right text-center"><c:out value="${siloEntryView.unitView.seals}"></c:out></div>
							<div style="width: 48px;" class="border-right text-right"><c:out value="${siloEntryView.unitView.amount}"></c:out></div>
							<div style="width: 53px;" class="border-right text-right"><c:out value="${siloEntryView.unitView.originWetness}"></c:out></div>
							<div style="width: 65px;" class="border-right text-center"><c:out value="${siloEntryView.unitView.date}"></c:out></div>
							<div style="width: 75px;" class="border-right text-center-field">
								<input type="text" name="SiloEntityForm.siloEntityViews[<c:out value="${index.count}"/>].receptionDate" class="textfields" style="height: 12px;margin-top:-2px;padding-left: 2px;width: 59px;" value="<c:out value="${siloEntryView.date}"/>"/>
							</div>
							<div style="width: 70px;" class="border-right text-center-field">
								<input type="text" name="SiloEntityForm.siloEntityViews[<c:out value="${index.count}"/>].ticket" class="textfields" style="height: 12px;margin-top:-2px;padding-left: 2px;width: 59px;"/>
							</div>
							<div style="width: 70px;" class="border-right text-center-field">
								<input type="text" name="SiloEntityForm.siloEntityViews[<c:out value="${index.count}"/>].weight" class="textfields" style="text-align:right;height: 12px;margin-top:-2px;padding-left: 2px;width: 35px;" value="<c:out value="${siloEntryView.amountTon}"/>"/>
							</div>
							<div style="width: 60px;" class="border-right text-center-field">
								<input type="text" name="SiloEntityForm.siloEntityViews[<c:out value="${index.count}"/>].wetness" class="textfields" style="text-align:right;height: 12px;margin-top:-2px;padding-left: 2px;width: 35px;" value="<c:out value="${siloEntryView.wetness}"/>"/>
							</div>
							<div style="width: 90px;" class="border-right text-center-field">
								<input type="text" name="SiloEntityForm.siloEntityViews[<c:out value="${index.count}"/>].location" class="textfields" style="height: 12px;margin-top:-2px;padding-left: 2px;width: 20px;text-align: center;" value="<c:out value="${siloEntryView.locationView.locationId}"/>"/> - 
								<input type="text" name="SiloEntityForm.siloEntityViews[<c:out value="${index.count}"/>].cornType" class="textfields" style="height: 12px;margin-top:-2px;padding-left: 2px;width: 30px;text-align: center;" value="<c:out value="${siloEntryView.locationView.cornTypeView.shortName}"/>"/>
							</div>
							<div style="width: 20px;"><img style="padding: 1px 0px 0px 2px;width: 16px;height: 16px;" src="img/ajax-loader.gif"/></div>
						</c:otherwise>
					</c:choose>
				</div>
			</c:forEach>
		</div>
		
		<div class="ctable" style="width: 939px;">
			<div class="cheader" style="margin-top: 10px;">
				<div style="width: 354px;" class="border-right"><bean:message key="list.scales"/></div>
				<div style="width: 581px;"><bean:message key="list.outputs"/></div>
			</div>
			
			<div class="cheadertitle">
				<div style="width: 53px;" class="border-right"><bean:message key="list.scales.id"/></div>
				<div style="width: 100px;" class="border-right"><bean:message key="list.scales.date"/></div>
				<div style="width: 50px;" class="border-right"><bean:message key="list.scales.silo"/></div>
				<div style="width: 55px;" class="border-right"><bean:message key="list.scales.corn"/></div>
				<div style="width: 92px;" class="border-right"><bean:message key="list.scales.weight"/></div>
				
				<div style="width: 20px;" class="border-right">&nbsp;</div>
				
				<div style="width: 90px;" class="border-right"><bean:message key="list.outputs.location"/></div>
				<div style="width: 80px;" class="border-right"><bean:message key="list.outputs.date"/></div>
				<div style="width: 150px;" class="border-right"><bean:message key="list.outputs.reason"/></div>
				<div style="width: 65px;" class="border-right"><bean:message key="list.outputs.weight"/></div>
				<div style="width: 150px;" class="border-right"><bean:message key="list.outputs.tank"/></div>
				<div style="width: 20px;">&nbsp;</div>
			</div>
			
			<c:forEach var="siloOutputView" items="${SiloEntityForm.siloOutputViews}" varStatus="index">
				<div class="crow <c:choose><c:when test="${index.count%2==0}">odd</c:when><c:otherwise>even</c:otherwise></c:choose>">
					<div style="width: 53px;" class="border-right text-center"><c:out value="${siloOutputView.id}"/></div>
					<div style="width: 100px;" class="border-right text-center"><c:out value="${siloOutputView.date}"/></div>
					<div style="width: 50px;" class="border-right text-center"><c:out value="${siloOutputView.locationView.locationId}"/></div>
					<div style="width: 55px;" class="border-right text-center" title="<c:out value="${siloOutputView.cornTypeView.description}"/>"><c:out value="${siloOutputView.cornTypeView.shortName}"/></div>
					<div style="width: 90px;" class="border-right text-right"><c:out value="${siloOutputView.amount}"/></div>
					
					<div style="width: 20px;" class="border-right text-center-field">
						<input type="checkbox" name="SiloEntityForm.siloOutputViews[<c:out value="${index.count}"/>].save" checked="checked"  style="margin-top: -2px;"/>
					</div>
					
					<div style="width: 90px;" class="border-right text-center-field">
						<input type="text" name="SiloEntityForm.siloOutputViews[<c:out value="${index.count}"/>].location" class="textfields" style="height: 12px;margin-top:-2px;padding-left: 2px;width: 20px;text-align: center;" value="<c:out value="${siloOutputView.locationView.locationId}"/>"/> - 
						<input type="text" name="SiloEntityForm.siloOutputViews[<c:out value="${index.count}"/>].cornType" class="textfields" style="height: 12px;margin-top:-2px;padding-left: 2px;width: 30px;text-align: center;" value="<c:out value="${siloOutputView.locationView.cornTypeView.shortName}"/>"/>
					</div>
					<div style="width: 80px;" class="border-right text-center-field">
						<input type="text" name="SiloEntityForm.siloOutputViews[<c:out value="${index.count}"/>].date" class="textfields" style="height: 12px;margin-top:-2px;padding-left: 2px;width: 59px;" value="<c:out value="${siloOutputView.date}"/>"/>
					</div>
					<div style="width: 150px;" class="border-right text-center-field">
						<input type="text" name="SiloEntityForm.siloOutputViews[<c:out value="${index.count}"/>].reasonCode" class="textfields" style="height: 12px;margin-top:-2px;padding-left: 2px;width: 30px;text-align: center;" value="<c:out value="${siloOutputView.reasonMovementView.code}"/>"/> - 
						<input type="text" name="SiloEntityForm.siloOutputViews[<c:out value="${index.count}"/>].reasonDescription" class="textfields" style="height: 12px;margin-top:-2px;padding-left: 2px;width: 90px;text-align: center;" value="<c:out value="${siloOutputView.reasonMovementView.description}"/>"/>
					</div>
					<div style="width: 65px;" class="border-right text-center-field">
						<input type="text" name="SiloEntityForm.siloOutputViews[<c:out value="${index.count}"/>].weight" class="textfields" style="text-align:right;height: 12px;margin-top:-2px;padding-left: 2px;width: 35px;" value="<c:out value="${siloOutputView.amountTon}"/>"/>
					</div>
					<div style="width: 150px;" class="border-right text-center-field">
						<input type="text" name="SiloEntityForm.siloOutputViews[<c:out value="${index.count}"/>].tank" class="textfields" style="height: 12px;margin-top:-2px;padding-left: 2px;width: 120px;"/>
					</div>
					<div style="width: 20px;"><img style="padding: 1px 0px 0px 2px;width: 16px;height: 16px;" src="img/exito.png"/></div>
				</div>
			</c:forEach>
		</div>
	</div>
</div>